from Sensor import Sensor
from BonyLandmark import BonyLandmark
import cPickle

import sys
import numpy
sys.modules['numpy.core.defmatrix'] = numpy.matrixlib.defmatrix

##  Saves and loads recordings.
class RecordingsProcessor:

    ##  The constructor of RecordingsProcessor.
    #   @param[in]  parent  The wx window parent (VisualizationState) of this Panel.
    #   @param[in]  main    Main wx.App derived instance.
    def __init__(self, parent, main):
        ##  The wx window parent (VisualizationState) of this Panel.
        self.parent = parent
        ##  Main wx.App derived instance.
        self.main = main

    ##  Saves the measurement and recordings to a .fob file.
    #   @param[in]  filename            The name of the file to be saved.
    #   @param[in]  currentRecording    The recording being saved.
    def SaveRecording(self, filename, currentRecording):
        output = open(filename, 'wb', 1)
        cPickle.dump(currentRecording, output, 0)
        output.close()
        
    ##  Loads the recorded file specified.
    #   @param[in]  filename    The file to be loaded.
    def LoadRecording(self, filename):
        inputFile = open(filename, 'rb', 1)
        loadedRecording = cPickle.load(inputFile)
        inputFile.close()
        
        return loadedRecording